package com.carsys.utils;

import com.carsys.entity.DetailedOrder;
import com.carsys.entity.Order;
import com.carsys.mapper.OrderMapper;

/**
 * 把order对象转化为DetailedOrder对象
 */
public class Order2DetailedOrderUtils {
    public static DetailedOrder order2DetailedOrder(Order order,OrderMapper orderMapper,int id){
        DetailedOrder detailedOrder = new DetailedOrder();
        detailedOrder.setOid(order.getId());
        detailedOrder.setOprice(order.getOprice());
        detailedOrder.setOstatus(order.getStatus());
        int cid = order.getCid();
        int backid = order.getBackid();
        int getid = order.getGetid();
        detailedOrder.setCname(orderMapper.getCnameByCid(cid));
        detailedOrder.setGetcity(orderMapper.getGetCityByGetId(getid));
        detailedOrder.setBackcity(orderMapper.getBackCityByBackId(backid));
        int total = orderMapper.getCountById(id);
        detailedOrder.setTotal(total);

        return detailedOrder;
    }


}
